package com.shermanzhou.algorithm.sort;

/**
 * @author zhouchaoqun
 * @date 2018/10/22 下午3:58
 */
public class BubbleSort {

    public static void main(String[] args) {
        int[] arr = {10,8,4,2,7,1,5,6};
        sort(arr);
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }

    public static void sort(int[] arr) {
        for(int i=0; i<arr.length; i++) {
            for (int j=0; j<arr.length-1-i; j++) {
                if (arr[j] > arr[j+1]) {
                    int tmp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = tmp;
                }
            }
        }
    }
}
